<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
	<meta http-equiv="content-language" content="cz">
	<title>DNS-323 Bash script</title>	
<style type="text/css">
body {font-family: Tahoma; text-align: center }
h2 {text-align: center }
table { margin: 0 auto; border-style: solid; border-width: 1px; border-collapse: collapse; }
td { border-style: solid; border-width: 1px ; text-align: center}
.vypis { font-size: 10 }
</style>
</head>
<body>
<?

define("MAINDIR", "/Downloads/");
define("DESTDIR", "/mnt/HD_a2/media/");
// nic odeslano nebylo hgfhfghfghhgf
if (empty($_GET))
{
    echo "<h2>Výpis složky:</h2><br>";
    $handleMain = opendir(MAINDIR);
    echo "<table>";
    while (($fileMain = readdir($handleMain)) != false)
    {
        echo "<tr><td>$fileMain</td><td>" . getSize(MAINDIR . $fileMain) . "</td></tr>";
    }
    echo "</table>";
}


function getSize($path)
{
    $size = filesize($path);
    if ($size < 1024)
        return "<span style='color: green'>" . (0 + $size) . " B</span>";
    if ($size >= 1024 && $size < 1048756)
        return round(($size / 1024), 2) . " kB";
    return "<span style='color: red;font-weight: bold'>" . round(($size / 1048756),
        2) . " MB</span>";
}

?>
<br><br><br>
</body>
</html>